
const express = require('express');
const router = express.Router();


router.get('', (req, res) => {
    const data = [];
    for(let i = 1; i < 51; i++)
        data.push({
            id: `${i}`,
            code: `string${i}`,
            serviceName: `string${i}`,
            brandId: 'brandId',
            brandCode: 'string',
            brandName: 'string',
            dealerId: 'dealerId',
            dealerCode: 'string',
            dealerName: 'string',
            serviceType: 1,
            chargeMode: 1,
            laborFee: 1000,
            materialFee: 100,
            otherFee: 200,
            scope: 1,
            startTime: '2019-05-10T07:11:29.144Z',
            endTime: '2019-05-10T07:11:29.144Z',
            status: 1,
            rowVersion: 'string',
            options: [
                'update',
                'abandon',
                'publish',
            ]
        });
    const {pageIndex, pageSize} = req.query;
    res.json({
        message: 'ok',
        payload: {
            content: data,
            pageIndex: parseInt(pageIndex, 10),
            pageSize: parseInt(pageSize, 10),
            totalElements: 50
        }
    });
});


router.get('/:id', (req, res) => {
    const {id} = req.params;
    res.json({
        message: 'ok',
        payload: {
            id: `${id}`,
            code: 'string',
            serviceName: 'string',
            serviceType: 1,
            content: 'string',
            brandId: 'brandId',
            brandCode: 'string',
            brandName: 'string',
            dealerId: 'dealerId',
            dealerCode: 'string',
            dealerName: 'string',
            chargeMode: 1,
            frequency: 10,
            isRestrictedQuantity: true,
            serviceQuantity: 10,
            laborFee: 100,
            materialFee: 100,
            otherFee: 100,
            needMgmtFee: true,
            scope: 1,
            startTime: '2019-05-10T07:14:56.066Z',
            endTime: '2019-05-10T07:14:56.066Z',
            status: 1,
            remark: 'string',
            rowVersion: 'string',
            options: [
                'update',
                'abandon',
                'publish'
            ],
            materials: [
                {
                    id: 'string',
                    usedPartId: 'string',
                    usedPartCode: 'string',
                    usedPartName: 'string',
                    usedPartSupplierId: 'string',
                    usedPartSupplierCode: 'string',
                    usedPartSupplierName: 'string',
                    newPartId: 'string',
                    newPartCode: 'string',
                    newPartName: 'string',
                    newPartSupplierId: 'string',
                    newPartSupplierCode: 'string',
                    newPartSupplierName: 'string',
                    price: 100,
                    quantity: 10,
                },
                {
                    id: 'string33',
                    usedPartId: 'string3',
                    usedPartCode: 'string3',
                    usedPartName: 'string3',
                    usedPartSupplierId: 'string3',
                    usedPartSupplierCode: 'string3',
                    usedPartSupplierName: 'string3',
                    newPartId: 'string3',
                    newPartCode: 'string3',
                    newPartName: 'string3',
                    newPartSupplierId: 'string3',
                    newPartSupplierCode: 'string3',
                    newPartSupplierName: 'string3',
                    price: 100,
                    quantity: 10,
                }
            ],
            workItems: [
                {
                    id: 'string',
                    partCode: 'partCode',
                    workItemId: 'string',
                    workItemCode: 'string',
                    workItemName: 'string',
                    isCaused: true,
                    materialFee: 100,
                    laborHour: 12,
                },
                {
                    id: 'string2',
                    partCode: 'partCode',
                    workItemId: 'string2',
                    workItemCode: 'string2',
                    workItemName: 'string2',
                    isCaused: false,
                    materialFee: 100,
                    laborHour: 6,
                }
            ],
            vehicles: [
                {
                    id: 'string1',
                    vehicleId: 'string1',
                    vin: 'string1',
                    dutyDealerCode: 'dutyDealerCode1',
                },
                {
                    id: 'string2',
                    vehicleId: 'string2',
                    vin: 'string2',
                    dutyDealerCode: 'dutyDealerCode2',
                }
            ],
            conditions: [
                {
                    id: 'string1',
                    conditionName: 1,
                    dataType: 1,
                    operator: 3,
                    value: '2019-05-10T07:14:56.066Z',
                    conditionValues: [
                        {
                            id: 'string1',
                            valueId: 'string1',
                            valueCode: 'string1'
                        },
                        {
                            id: 'string2',
                            valueId: 'string2',
                            valueCode: 'string2'
                        }
                    ]
                },
                {
                    id: 'string2',
                    conditionName: 2,
                    dataType: 1,
                    operator: 3,
                    value: '2019-05-10T07:14:56.066Z',
                    conditionValues: [
                        {
                            id: 'string11',
                            valueId: 'string11',
                            valueCode: 'string11'
                        },
                        {
                            id: 'string22',
                            valueId: 'string22',
                            valueCode: 'string22'
                        }
                    ]
                },
                {
                    id: 'string3',
                    conditionName: 3,
                    dataType: 2,
                    operator: 2,
                    value: '2019-05-10T07:14:56.066Z',
                }
            ],
            dealerQuotas: [
                {
                    id: 'string',
                    dealerId: 'string',
                    dealerCode: 'string',
                    dealerName: 'string',
                    quota: 5
                }
            ]
        }
    });
});

router.put('/:id/publish', (req, res) => {
    res.json({
        message: '成功'
    });
});


router.put('/:id/abandon', (req, res) => {
    res.json({
        message: '成功'
    });
});

router.put('/:id', (req, res) => {
    res.json({message: '修改成功'});
});

router.post('/', (req, res) => {
    res.json({
        message: '新增成功'
    });
});

module.exports = router;
